<div id="container">
    <h1>Thêm dịch vụ</h1>
    <script type="text/javascript" src="js/services.js"></script>
    <link type="text/css" rel="stylesheet" href="css/services.css"/>

    <?php echo form_open(current_url(), array('id' => 'addservice')); ?>
    <div id = "top_reserve">
        <div  id = "content-right" class="action">
        <div>
            <p>
                <input type="image" id="button_submit" name="button_submit" value="Lưu" class="imageButtonSmall"/>
                <?php
                /* Cancel button */
                $data = array(
                    'name' => 'button_cancel',
                    'id' => 'button_cancel',
                    'value' => 'true',
                    'type' => 'button',
                    'content' => 'Hủy',
                    'onclick' => "history.go(-1);return false;"
                );

                echo form_button($data);
                ?>
            </p>
        </div>
            </div> <!-- end opt_box -->
        <!-- end add_new -->
    </div>
    <!-- end top_reserve -->
    <div style="width: 500px; margin: 0 auto;">
        <?php echo $custom_error; ?>
        <?php
        $Serv_ID = set_value('Serv_ID');
        if (!$Serv_ID)
            $Serv_ID = $temp_id;
        ?>
        <input id="Serv_ID" type="hidden" name="Serv_ID"
               value="<?php echo $Serv_ID; ?>" /> <span
               style="clear: both; padding: 5px;"><p>
                <label
                    style="float: left; text-align: right; margin-right: 5px; width: 135px;"
                    for="Price">Danh mục</label>
            <div class="styled-select">
                    <?php echo $combobox_cats; ?>
            </div>
            </p> </span> <span style="clear: both; float: left; padding: 5px;">
            <p>
                <label
                    style="float: left; text-align: right; margin-right: 5px; width: 135px;"
                    for="Serv_Name">Tên dịch vụ<span class="required"><font color="red">*</font>
                    </span>
                </label>
                <input id="Serv_Name" rows="5" cols="35" name="Serv_Name" value="<?php echo set_value('Serv_Name'); ?>"/>
                <?php echo form_error('Serv_Name', '<div class="error">', '</div>');
                ?>
            </p>
        </span>
		<span style="clear: both; float: left; padding: 5px;">
            <p>
                <label
                    style="float: left; text-align: right; margin-right: 5px; width: 135px;"
                    for="Price">Giá<span class="required"><font color="red">*</font> </span>
                </label> <input id="Price" type="text" name="Price"
                                value="<?php
                                echo
                                set_value('Price');
                                ?>" />
                                <?php echo form_error('Price', '<div class="error">', '</div>'); ?>
            </p>
        </span>
        <!-- Vip -->
        <span style="clear: both; padding: 5px;">
            <p>
                <?php
                $value = ((empty($services_vip) && (0 === sizeof($services_vip)))) && (0 == $combobox_vip_first) ? '0' : '1';
                $checked = (empty($services_vip) && (0 === sizeof($services_vip))) && (0 == $combobox_vip_first) ? FALSE : TRUE;
                echo form_checkbox('vip', $value, $checked, 'id="vip" style="display:none"');
                ?>
                <label id='vip_label'
                       style="text-align: right; margin-right: 5px; width: 135px; display:none"
                       for="vip">VIP</label>
            </p>
        </span>
        <!-- @var $combobox_vip_first type : equal 0 if first catefory isn't vip or table empty, else equal 1 -->
        <div id="chitiet" <?php echo ($checked || 1 == $combobox_vip_first ) ? 'style="display:block;"' : 'style="display:none;"'; ?> >
            <!-- tabs -->
            <div id="tabs">
                <ul>
                    <?php
                    // Load all categories
                    foreach ($categories as $k => $v) {
                        $style = "";
                        $selected = "";
                        $services_name = preg_replace('#[^\w()/.%\-&]#', "", $v['Name']);
                        foreach ($v['services'] as $kk => $vv) {
                            if (in_array($vv['Serv_ID'], $services_vip)) {
                                $selected = 'class="ui-state-default-selected"';
                            }
                        }
                        if ($k > 5)
                            $style = 'style="position: relative; top: -13px;left:0px;"';
                        echo '<li ' . $selected . ' ' . $style . '><a title="' . $v['Name'] . '" href="#' . preg_replace('#[^\w()/.%\-&]#', "", $v['Name']) . '"><p class="blocktext">' . cat_chuoi($v['Name'], 13) . '</p></a></li>';
                    }
                    ?>
                </ul>
                <?php
                // With each a category
                foreach ($categories as $k => $v) {
                    ?>
                    <div id="<?php echo preg_replace('#[^\w()/.%\-&]#', "", $v['Name']); ?>" class="ui-tabs-panel ui-widget-content ui-corner-bottom">
                        <?php
                        // Then load all services
                        foreach ($v['services'] as $kk => $vv) {
                            ?>
                            <div class="item<?php echo in_array($vv['Serv_ID'], $services_vip) ? ' selected' : ''; ?>"  style="border: 1px solid transparent;">
                                <span title="<?php echo $vv['Serv_Name']; ?>"><?php echo cat_chuoi($vv['Serv_Name'], 20); ?></span>
                                <input type="hidden" value="<?php echo $vv['Serv_ID'] ?>" name="<?php echo in_array($vv['Serv_ID'], $services_vip) ? 'services[]' : ''; ?>" />
                            </div>
                            <?php
                        }
                        ?>
                    </div>
                    <?php
                }
                ?>

            </div>
            <!-- end tabs -->
        </div>
        <!-- end chi tiet -->
        <!-- END Vip -->
        <span style="clear: both; float: left; padding: 5px;">
            <p>
                <label
                    style="float: left; text-align: right; margin-right: 5px; width: 135px;"
                    for="Serv_Name_EN">Tên tiếng anh</label> <input id="Serv_Name_EN"
                    type="text" name="Serv_Name_EN"
                    value="<?php
                    echo
                    set_value('Serv_Name_EN');
                    ?>" />
                    <?php echo form_error('Serv_Name_EN', '<div class="error">', '</div>');
                    ?>
            </p>
        </span> <span style="clear: both; float: left; padding: 5px;">
            <p>
                <label
                    style="float: left; text-align: right; margin-right: 5px; width: 135px;"
                    for="Price">Thời gian</label> <input id="Time" type="text"
                    name="Time" value="<?php
                    echo
                    set_value('Time');
                    ?>" />
                    <?php echo form_error('Time', '<div class="error">', '</div>'); ?>
            </p>
        </span> <span style="clear: both; float: left; padding: 5px;">
            <p>
                <label
                    style="float: left; text-align: right; margin-right: 5px; width: 135px;"
                    for="Price">Tien tip'</label> <input id="TienTip" type="text"
                    name="TienTip" value="<?php
                    echo
                    set_value('TienTip');
                    ?>" />
                    <?php echo form_error('TienTip', '<div class="error">', '</div>'); ?>
            </p>
        </span> <span style="clear: both; float: left; padding: 5px;">
            <p>
                <label
                    style="float: left; text-align: right; margin-right: 5px; width: 135px;"
                    for="Percent_Service">% dịch vụ</label> <input id="Percent_Serv"
                    type="text" name="Percent_Serv"
                    value="<?php
                    echo
                    set_value('Percent_Serv');
                    ?>" />
                    <?php echo form_error('Percent_Serv', '<div class="error">', '</div>');
                    ?>
            </p>
        </span>
        <span style="clear: both; float: left; padding: 5px;">
            <p>
                <label
                    style="float: left; text-align: right; margin-right: 5px; width: 135px;"
                    for="Descriptions">Mô tả</label> <textarea id="Descriptions"
                    rows="4" cols="16" name="Descriptions" ><?php
                       echo set_value('Descriptions');?>
                    </textarea>
                <?php echo form_error('Descriptions', '<div class="error">', '</div>');
                ?>
            </p>
        </span>
    </div>
    <?php echo form_close(); ?>
</div>
<script type="text/javascript">
    $(function() {
        $("#chitiet #tabs ul li").click(function() {
            $(this).find("a").click();
        });
    });
</script>
